package cn.hclab.util;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.ScrollView;
import android.widget.TextView;

public class UIUtilities {
	static public void showAlert(Context context, String title, String text) {

		DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
			}
		};

		UIUtilities.showAlert(context, title, text, listener);
	}

	static public void showAlert(Context context, String title, String text, DialogInterface.OnClickListener listener) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setMessage(text);
		if (title != null) {
			builder.setTitle(title);
		}

		builder.setPositiveButton("OK", listener);

		AlertDialog alert = builder.create();
		alert.show();
	}

	static public void showTextInfo(Context context, String title, CharSequence text) {
		TextView textView = new TextView(context);
		textView.append(text);

		ScrollView scrollView = new ScrollView(context);
		scrollView.addView(textView);

		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		if (title != null) {
			builder.setTitle(title);
		}
		builder.setView(scrollView);
		builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
			}
		});

		AlertDialog alert = builder.create();
		alert.show();
	}

}